//
//  ZDBaseViewController.m
//  ZHIDOU
//
//  Created by 向礼 on 2018/12/18.
//  Copyright © 2018 向礼. All rights reserved.
//

#import "ZDBaseViewController.h"
#import "FLBNavgationController.h"

@interface ZDBaseViewController ()

@end

@implementation ZDBaseViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navController.navStyle = DesignNavBackgroundStyle_Default;
    self.navController.isWebView = NO;
   [self.navController setNavigationBarHidden:NO animated:animated];
    // 返回手势
    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]){
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = ZD_backgroundColor;
}


// 重写获取navigationController的方法
- (FLBNavgationController *)navController {
    if (self.navigationController) {
        return (FLBNavgationController *)self.navigationController;
    }
    return nil;
}

- (CGFloat)bottomSafeAreaInsets
{
    UIEdgeInsets edgeInsets = [self mcEdgeInsetsSafeAreaInset];
    NSLog(@"%lf---%lf----%lf",edgeInsets.bottom ,[self navBottom],ZD_statusBarHeight);
    return edgeInsets.bottom + [self navBottom];
}

- (CGFloat)navBottom
{
    return self.navigationController.navigationBar.bottom;
}


- (UIEdgeInsets)mcEdgeInsetsSafeAreaInset
{
    UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero;
    if (@available(iOS 11.0, *)) {
        safeAreaInsets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;
        
    }else {
        safeAreaInsets =  UIEdgeInsetsMake(ZD_statusBarHeight, 0, 0, 0);
    }
    
    return safeAreaInsets;
}

@end
